import { request } from '@/utils/request'
import type { User, CodeType, UserInfo, PatientList } from '@/types/user'

// 密码登录
export const loginByPassword = (mobile: string, password: string) => {
  return request<User>('/login/password', 'POST', { mobile, password })
}

// 获取短信验证码
export const sendMobileCode = (mobile: string, type: CodeType = 'login') => {
  return request<{ code: string }>('/code', 'GET', { mobile, type })
}

// 短信验证码登录
export const loginByMobile = (mobile: string, code: string) => {
  return request<User>('/login', 'POST', { mobile, code })
}

// 获取用户信息
export const getUserInfo = () => {
  return request<UserInfo>('/patient/myUser')
}

// 获取患者列表
// 获患者信息列表
export const getPatientList = () => request<PatientList>('/patient/mylist')
